package com.sesum;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.database.sqlite.SQLiteDatabase.CursorFactory;

public class UserSQLiteOpenHelper extends SQLiteOpenHelper {

	private String sqlCreateUsers = "CREATE TABLE IF NOT EXISTS users (login VARCHAR(50) PRIMARY KEY, password VARCHAR(50) NOT NULL, car_registration VARCHAR(15) NOT NULL, state VARCHAR(5) NOT NULL)";
	private String sqlDropUsers = "DROP TABLE IF EXISTS users";
	

	public UserSQLiteOpenHelper(Context context, String name,
			CursorFactory factory, int version) {
		super(context, name, factory, version);
		// TODO Auto-generated constructor stub
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		// TODO Auto-generated method stub
		//Se ejecuta la sentencia SQL de creación de la tabla
        db.execSQL(sqlCreateUsers );
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
	   //Se elimina la versión anterior de la tabla
        db.execSQL(sqlDropUsers);
 
        //Se crea la nueva versión de la tabla
        db.execSQL(sqlCreateUsers);

	}

}



